<?php
/**
 * ImpSoft Model Row Base
 * All model rows in the app extend this guy
 * 
 * @package ImpSoft
 * @subpackage ImpSoft Models
 * @copyright Luke Visinoni (luke.visinoni@gmail.com)
 * @author Luke Visinoni (luke.visinoni@gmail.com)
 * @license GNU Lesser General Public License
 */
class ImpSoft_Db_Table_Row extends Zend_Db_Table_Row {

	/** Disabled because Zend_Db_Table_Row_Abstract already has it
    public function setFromArray($data, $strict = false) {
    
        if (!$strict) {
            $data = array_intersect_key($data, array_flip($this->_table->getColumns()));
        }
        return parent::setFromArray($data);
    
    } **/
    /**
     * Allows pre-insert logic to be applied to row.
     *
     * @return void
     */
    protected function _insert() {
	
		if (array_key_exists('created', $this->_data) && empty($this->_data['created'])) {
			$this->created = new Zend_Db_Expr('NOW()');
		}
		if (array_key_exists('modified', $this->_data) && empty($this->_data['modified'])) {
			$this->modified = new Zend_Db_Expr('NOW()');
		}
	
    }
    /**
     * Allows pre-update logic to be applied to row.
     *
     * @return void
     */
    protected function _update() {
	
		if (array_key_exists('modified', $this->_data)) {
			$this->modified = new Zend_Db_Expr('NOW()');
		}
	
    }

}